/*****************************************************
 Replication code for "Who is Powerful?"
 input file: transtemp.dta
 Jonathan Slapin, April 2006 
*********************************************************/

use transtemp.dta

* Create Table 3 
* Count number of status quo changes. Each variable is a constant that counts an actor's distance from the sq

egen compos=sum(com)
egen eppos=sum(ep)
egen bpos=sum(b)
egen dkpos=sum(dk)
egen dpos=sum(d)
egen grpos=sum(gr)
egen epos=sum(e)
egen fpos=sum(f)
egen irlpos=sum(irl)
egen ipos=sum(i)
egen luxpos=sum(lux)
egen nlpos=sum(nl)
egen apos=sum(a)
egen ppos=sum(p)
egen sfpos=sum(sf)
egen spos=sum(s)
egen ukpos=sum(uk)

* calculate winning percentage for each actor

gen winep=1 if ep==am
replace winep=0 if ep~=am
egen winpep=sum(winep)
replace winpep=winpep/228

gen wincom=1 if com==am
replace wincom=0 if com~=am
egen winpcom=sum(wincom)
replace winpcom=winpcom/228

gen winb=1 if b==am
replace winb=0 if b~=am
egen winpb=sum(winb)
replace winpb=winpb/228

gen windk=1 if dk==am
replace windk=0 if dk~=am
egen winpdk=sum(windk)
replace winpdk=winpdk/228

gen wind=1 if d==am
replace wind=0 if d~=am
egen winpd=sum(wind)
replace winpd=winpd/228

gen wingr=1 if gr==am
replace wingr=0 if gr~=am
egen winpgr=sum(wingr)
replace winpgr=winpgr/228

gen wine=1 if e==am
replace wine=0 if e~=am
egen winpe=sum(wine)
replace winpe=winpe/228

gen winf=1 if f==am
replace winf=0 if f~=am
egen winpf=sum(winf)
replace winpf=winf/228

gen winirl=1 if irl==am
replace winirl=0 if irl~=am
egen winpirl=sum(winirl)
replace winpirl=winpirl/228

gen wini=1 if i==am
replace wini=0 if i~=am
egen winpi=sum(wini)
replace winpi=winpi/228

gen winlux=1 if lux==am
replace winlux=0 if lux~=am
egen winplux=sum(winlux)
replace winplux=winplux/228

gen winnl=1 if nl==am
replace winnl=0 if nl~=am
egen winpnl=sum(winnl)
replace winpnl=winpnl/228

gen wina=1 if a==am
replace wina=0 if a~=am
egen winpa=sum(wina)
replace winpa=winpa/228

gen winp=1 if p==am
replace winp=0 if p~=am
egen winpp=sum(winp)
replace winpp=winpp/228

gen winsf=1 if sf==am
replace winsf=0 if sf~=am
egen winpsf=sum(winsf)
replace winpsf=winpsf/228

gen wins=1 if s==am
replace wins=0 if s~=am
egen winps=sum(wins)
replace winps=winps/228

gen winuk=1 if uk==am
replace winuk=0 if uk~=am
egen winpuk=sum(winuk)
replace winpuk=winpuk/228

* This code transforms the data so if a member state does not want to change the status quo,
* the mem state's position becomes a -1. 
* this is the data I will use in the probit analysis 

replace com =2*com-1
replace ep=2*ep-1
replace b=2*b-1
replace dk=2*dk-1
replace d=2*d-1
replace gr=2*gr-1
replace e=2*e-1
replace f=2*f-1
replace irl=2*irl-1
replace i=2*i-1
replace lux=2*lux-1
replace nl=2*nl-1
replace a=2*a-1
replace p=2*p-1
replace sf=2*sf-1
replace s=2*s-1
replace uk=2*uk-1

/* These run the probit models */
/* These are NOT the models reported in the paper. Those were run in R, which gives very slightly different results. */
/* These do, however, demonstrate that the robust standard errors do not change the results substantially. */
probit am com ep b dk d gr e f irl i lux nl a p sf s uk, nocon 
probit am com ep b dk d gr e f irl i lux nl a p sf s uk, nocon robust

* another potential model which corrects for the fact that Stata's probit command
* makes anything not equal to zero equal to 1. Again, very similar to, but slightly different than the R code

glm am ep com b dk d gr e f irl i lux nl a p sf s uk, nocon family(bin) link(probit)  
glm am ep com b dk d gr e f irl i lux nl a p sf s uk, nocon family(bin) link(probit)  robust
glm am ep com b dk d gr e f irl i lux nl a p sf s uk, nocon family(bin) link(probit)  robust cluster(ia)



